package com.bawei.doctor.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.bawei.doctor.entity.DoctorPatientMidEntity;
import com.bawei.doctor.service.DoctorPatientMidService;
import com.bawei.common.utils.PageUtils;
import com.bawei.common.utils.R;



/**
 * 医生患者中间表
 *
 * @author wtj
 * @email 1756179378@qq.com
 * @date 2021-12-09 16:49:01
 */
@RestController
@RequestMapping("doctor/doctorpatientmid")
public class DoctorPatientMidController {
    @Autowired
    private DoctorPatientMidService doctorPatientMidService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = doctorPatientMidService.queryPage(params);

        return R.ok().put("page", page);
    }

    /**
     *  查询该医师下的患者统计信息
     */
    @GetMapping("/patientparticulars")  //患者详情
    public R patientparticulars(@RequestParam("doctorId") int doctorId,
                                @RequestParam(value = "page",defaultValue = "1")int page,
                                @RequestParam(value = "size",defaultValue = "2") int size){
        PageUtils patientparticulars=doctorPatientMidService.patientparticulars(doctorId,page,size);

        return R.ok().put("patientparticulars",patientparticulars);
    }
    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Integer id){
		DoctorPatientMidEntity doctorPatientMid = doctorPatientMidService.getById(id);

        return R.ok().put("doctorPatientMid", doctorPatientMid);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody DoctorPatientMidEntity doctorPatientMid){
		doctorPatientMidService.save(doctorPatientMid);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody DoctorPatientMidEntity doctorPatientMid){
		doctorPatientMidService.updateById(doctorPatientMid);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] ids){
		doctorPatientMidService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
